package org.leo.dm.util;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 
 * Created on 2016年2月17日
 * <p> 
 * Description 对象操作工具类
 * <p> 
 * Copyright neusoft (c) 2015 .
 * 
 * @author xiao_h 
 *
 */
public class ObjectUtil {
	public static Map<Object, Object> arrayToMap(Object[] str1, Object[] str2) {
		Map<Object, Object> mapping = new HashMap<Object, Object>();
		for (int i = 0; i < str1.length; i++) {
			mapping.put(str1[i], str2[i]);
		}
		return mapping;
	}

	public static Map<Object, Object> listToMap(List<Object> list1, List<Object> list2) {
		Map<Object, Object> mapping = new HashMap<Object, Object>();
		int list1Size = list1.size();
		for (int i = 0; i < list1Size; i++) {
			mapping.put(list1.get(i), list2.get(i));
		}
		return mapping;
	}

	public static String nullChange(Object o) {
		if (o == null) {
			return "";
		}
		return String.valueOf(o);
	}

	// 转化字符串为十六进制编码
	public static String toHexString(String s) {
		String str = "";
		for (int i = 0; i < s.length(); i++) {
			int ch = (int) s.charAt(i);
			String s4 = Integer.toHexString(ch);
			str = str + s4;
		}
		return str;
	}
}
